﻿using BalloonShop.App_Code;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace BalloonShop.UserControls
{
    public partial class CategoriesList : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //获取所选分类的ID
            string departmentId = Request.QueryString["DepartmentID"];
            //仅当查询字符串中包含DepartmentID时继续
            if (departmentId != null)
            {
                //Catalog.GetCategoriesInDepartment将返回一个DataTable对象，
                //它包含DataList显示的分类数据
                list.DataSource = CatalogAccess.GetCatagoriesInDepartment(departmentId);
                //需要为数据绑定控件绑定数据源
                list.DataBind();
            }
        }

        public string GetCategory(string departmentId,string categoryId)
        {
            return Link.ToCategory(departmentId,categoryId);
        }
    }
}